<?php


namespace app\admin\controller;

use app\admin\model\Company;

/**
 * Class Member
 * @package app\admin\controller
 * 后台组织架构
 */
class Structure extends Admin
{
    /**
     * 企业简介
     */
    public function company()
    {
        $companyModel = new Company();
        if(IS_POST) {
            $data = input('post.');
            if($data['id']) {
                $data['update_time'] = time();
                $res = $companyModel->save($data,['id' => $data['id']]);
                if($res) {
                    return $this->success("修改成功");
                }else {
                    return $this->error("修改失败");
                }
            }else {
                unset($data['id']);
                $res = $companyModel->save($data);
                if($res) {
                    return $this->success("新增成功");
                }else {
                    return $this->error("新增失败");
                }
            }
        }else {
            $company = Company::get();
            $this->assign('msg',$company);
            return $this->fetch();
        }
    }
}